<template>
  <view class="app-popup-background" v-show="visible"
    :class="[visible ? 'popup-show' : 'popuphide', hasFooter ? 'has-footer' : '']" catchtouchmove="ture">
    <view class="app-popup-rbga" @click.stop="close"></view>
    <view class="app-popup">
      <view class="_right-top-option-wrapper _del-option" @click.stop="close">
        <view class="_shadow"></view>
        <view class="_box">
          <image class="_icon" :src="stitchingURL('icons/delete-white')"></image>
        </view>
      </view>
      <slot></slot>
    </view>
  </view>
</template>

<script>
import {
  stitchingURL,
} from "@/common/util.js";

export default {
  name: "uni-detail-popup",
  props: {
    title: [Number, String],
    hasFooter: {
      type: Boolean,
      default: false
    },
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  methods: {
    stitchingURL,
    close() {
      // 关闭popup
      this.$emit("onClose");
    },
  },
};
</script>

<style lang="scss">
@keyframes hide {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(100%);
  }
}

@keyframes show {
  0% {
    transform: translateY(100%);
  }

  100% {
    transform: translateY(0);
  }
}

.app-popup-background {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;

  &.has-footer {
    bottom: 124upx;
  }

  &.min-hide {
    .popup-popup {
      animation: hide 0.1s linear forwards;
    }

    .app-popup-turnoff {
      opacity: 0;
    }
  }

  &.popup-show {
    .app-popup {
      animation: show 0.1s linear forwards;
    }

    .app-popup-turnoff {
      opacity: 1;
    }
  }

  .app-popup-rbga {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
  }

  .app-popup {
    width: 100%;
    background: #ffffff;
    position: absolute;
    bottom: 0;
    left: 0;
    height: auto;
    overflow: hidden;
    z-index: 2;
    border-radius: 23upx 23upx 0upx 0upx;
    // transform: translate3d(0, 100%, 0);


    ._right-top-option-wrapper {
      position: absolute;
      z-index: 1;
      top: 0;
      right: 0;
      width: 50upx;
      height: 48upx;
      border-bottom-left-radius: 38upx;
      overflow: hidden;
      background: transparent;

      ._shadow {
        position: absolute;
        z-index: 1;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
      }

      &._del-option ._shadow {
        background: #1F1F1F;
      }

      ._box {
        position: absolute;
        z-index: 2;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background: transparent;
        display: flex;
        align-items: flex-start;
        justify-content: flex-end;
      }

      &._del-option ._icon {
        width: 20upx;
        height: 20upx;
        margin-right: 14upx;
        margin-top: 14upx;
      }
    }

    .app-popup-top {
      height: 154upx;
      width: 100%;
      padding-top: 46upx;
      position: relative;

      .app-popup-title {
        color: #3a3a3a;
        font-size: 34upx;
        font-weight: bold;
        line-height: 53upx;
        text-align: center;
      }

      .app-popup-turnoff {
        width: 66rpx;
        height: 66rpx;
        padding: 20rpx;
        position: absolute;
        right: 25rpx;
        top: 42rpx;
      }

      .app-popup-secondary-title {
        position: absolute;
        bottom: 0;
        left: 0;
        height: 50upx;
        width: 100%;
        background: #fbfbfc;
        line-height: 50upx;
        text-align: center;
        font-size: 26upx;
        color: #9b9b9b;
      }
    }

    .app-popup-view {
      position: absolute;
      top: 154rpx;
      bottom: 50upx;
      left: 0;
      right: 0;
      -webkit-overflow-scrolling: touch;
    }

    .app-popup-tip {
      width: 100%;
      height: 70upx;
      position: absolute;
      padding-top: 6upx;
      left: 0;
      bottom: 0;
      color: #ef233c;
      background: #fef7f7;
      border-radius: 23upx 23upx 0upx 0upx;
      font-size: 26upx;
      text-align: center;
    }
  }
}
</style>
